package com.yanqu.road.server.cmd.variety;

import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.pb.variety.VarietyProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;

/**
 * @author ：zfr
 * @date ：2021/2/20 15:24
 */
@Cmd(code = CrossProtocol.C_VARIETY_SYNC_GROUP_SERVER_LIST, desc = "同步分组区服列表")
public class SyncGroupServerListCrossCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        VarietyProto.SyncGroupServerRespMsg.Builder builder = VarietyProto.SyncGroupServerRespMsg.newBuilder();
        builder.setVarietyBeginTime(GameConfig.VARIETY_BEGIN_TIME);
        builder.setVarietyEndTime(GameConfig.VARIETY_END_TIME);
        builder.addServerId(serverId);
//        MatchServerGroup group = MatchServerGroupMgr.getServerGroupByServerId(serverId);
//        if (group != null) {
//            if (group.getMatchState() == 1) {
//                builder.addAllServerId(group.getServerList());
//            }
//        }
        YanQuMessage message = YanQuMessageUtils.buildMessage(ClientProtocol.U_VARIETY_SYNC_GROUP_SERVER_LIST, builder);
        MessageHelper.sendPacket(serverId, packet.getPlayerId(), message);
    }

    @Override
    public void sendData() {

    }
}
